package org.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.demo.entity.Housewear;
import org.demo.mapper.HousewearMapper;
import org.demo.service.IHousewearService;
import org.demo.service.IOrderIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class HousewearServiceImpl extends ServiceImpl<HousewearMapper, Housewear> implements IHousewearService {
    @Autowired
    private HousewearMapper housewearMapper;
    @Autowired
    private IOrderIdService orderIdService;


    @Override
    public void add(Housewear housewear) {
        String id = orderIdService.getId("HOUSEWEAR");
        housewear.setId(id);
        save(housewear);
    }

    @Override
    public List<Housewear> list(Housewear housewear) {
        if (housewear==null){
            List<Housewear> houses=housewearMapper.selectList(null);
            return houses;
        }else {
            List<Housewear> houses=lambdaQuery().eq(Housewear::getId,housewear.getId()).list();
            return houses;
        }
    }

    @Override
    public void update(Housewear housewear) {
        lambdaUpdate().eq(Housewear::getId,housewear.getId()).update();
    }

    @Override
    public void delete(String id) {
        housewearMapper.deleteById(id);
    }
}
